Defining functions using fn

Functions in Clojure are assigned using the defn keyword normally, but if you want to create an anonymous function in Clojure, you would use the fn keyword.

(fn [] 
 (println "anonymous function!"))

Defining function using defn

To define named functions, use the defn keyword. This keyword is used the exact same way as anonymous functions accent the first argument is the function name.

(fn fun-name [] 
 (println "anonymous function!"))